//
//  IGScrollSetCell.m
//  jingdongfang
//
//  Created by BOE on 2017/8/25.
//  Copyright © 2017年 LJL. All rights reserved.
//

#import "IGScrollSetCell.h"
#import "IGCommon.h"

static NSString *const kIGScrollSetCell = @"kIGScrollSetCell";
@implementation IGScrollSetCell

+ (IGScrollSetCell *)cellWithTableView:(UITableView *)tableView {
    IGScrollSetCell *cell = [tableView dequeueReusableCellWithIdentifier:kIGScrollSetCell];
    if (!cell) {
        cell = [[IGScrollSetCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kIGScrollSetCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        UILabel *titleLabel = [[UILabel alloc] init];
//        titleLabel.text = @"轮播内容";
        titleLabel.text = NSLocalizedString(@"Loop Content", nil);
        titleLabel.font = [UIFont font16];
        titleLabel.textColor = [UIColor c4Color];
        [self.contentView addSubview:titleLabel];
        
        UIButton *gfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        gfBtn.tag = IGRemoteControlBtnGF;
        [gfBtn setBackgroundColor:[UIColor whiteColor]];
//        [gfBtn setTitle:@"官方" forState:UIControlStateNormal];
        [gfBtn setTitle:NSLocalizedString(@"Official", nil) forState:UIControlStateNormal];
        [gfBtn setTitleColor:[UIColor c4Color] forState:UIControlStateNormal];
        [gfBtn setTitleColor:[UIColor appColor] forState:UIControlStateSelected];
        [gfBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        gfBtn.layer.cornerRadius = 10;
        gfBtn.layer.borderWidth = .5;
        [self.contentView addSubview:gfBtn];
        
        UIButton *zbBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        zbBtn.tag = IGRemoteControlBtnGR;
        [zbBtn setBackgroundColor:[UIColor whiteColor]];
//        [zbBtn setTitle:@"个人" forState:UIControlStateNormal];
        [zbBtn setTitle:NSLocalizedString(@"Individual", nil) forState:UIControlStateNormal];
        [zbBtn setTitleColor:[UIColor c4Color] forState:UIControlStateNormal];
        [zbBtn setTitleColor:[UIColor appColor] forState:UIControlStateSelected];
        [zbBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        zbBtn.layer.cornerRadius = 10;
        zbBtn.layer.borderWidth = .5;
        [self.contentView addSubview:zbBtn];
        
        UIButton *fxBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        fxBtn.tag = IGRemoteControlBtnFX;
        [fxBtn setBackgroundColor:[UIColor whiteColor]];
//        [fxBtn setTitle:@"分享" forState:UIControlStateNormal];
        [fxBtn setTitle:NSLocalizedString(@"Sharing", nil) forState:UIControlStateNormal];
        [fxBtn setTitleColor:[UIColor c4Color] forState:UIControlStateNormal];
        [fxBtn setTitleColor:[UIColor appColor] forState:UIControlStateSelected];
        [fxBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        fxBtn.layer.cornerRadius = 10;
        fxBtn.layer.borderWidth = .5;
        [self.contentView addSubview:fxBtn];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kGAP15);
            make.top.mas_equalTo(kGAP10);
            make.width.mas_equalTo(KSCREENWIDTH - 20);
            make.height.mas_equalTo(40);
        }];
        
        [IGCommon makeEqualHeightWidthViews:@[gfBtn, zbBtn, fxBtn] inView:self.contentView viewHeight:30 lineNums:3 Tpadding:60 LRpadding:20 HPadding:0 VPadding:20];
    }
    
    return self;
}

- (void)btnClick:(UIButton *)sender {
    sender.selected = !(sender.selected);
    if (sender.selected) {
        sender.layer.borderColor = [UIColor appColor].CGColor;
    } else {
        sender.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    if (self.itemClickBlock) {
        self.itemClickBlock(sender.tag, sender.selected?@"1":@"0");
    }
}

- (void)setGfSelect:(BOOL)gfSelect {
    _gfSelect = gfSelect;
    
    UIButton *sender = [self viewWithTag:IGRemoteControlBtnGF];
    sender.selected = gfSelect;
    if (sender.selected) {
        sender.layer.borderColor = [UIColor appColor].CGColor;
    } else {
        sender.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
}

- (void)setZbSelect:(BOOL)zbSelect {
    _zbSelect = zbSelect;
    
    UIButton *sender = [self viewWithTag:IGRemoteControlBtnGR];
    sender.selected = zbSelect;
    if (sender.selected) {
        sender.layer.borderColor = [UIColor appColor].CGColor;
    } else {
        sender.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
}

- (void)setFxSelect:(BOOL)fxSelect {
    _fxSelect = fxSelect;
    
    UIButton *sender = [self viewWithTag:IGRemoteControlBtnFX];
    sender.selected = fxSelect;
    if (sender.selected) {
        sender.layer.borderColor = [UIColor appColor].CGColor;
    } else {
        sender.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
